<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	
  </head>
  
  <body>
  	<input type="button" class="btn btn-mini btn-info" 		value="增  加" id="add">
  	<input type="button" class="btn btn-mini btn-success" value="修  改" id="modify">
  	<input type="button" class="btn btn-mini btn-primary" value="维护用户关系" id="setRelation">
  	<input type="button" class="btn btn-mini btn-danger" 	value="删  除" id="delete">
  	<input type="button" class="btn btn-mini btn-warning" value="导 入" id="import">
    <div class="accordion-group widget-box">
      <div class="accordion-heading">
        <div class="widget-title"> 
        	<a data-parent="#collapse-group" href="#collapseGOne" data-toggle="collapse" class="collapsed">
         	<span class="icon"><i class="icon-search"></i></span>
          	<h5>检索条件</h5>
          	</a> 
        </div>
      </div>
      <div class="accordion-body in collapse" id="collapseGOne" style="height: auto;">
        <div class="form-horizontal">
        	<div class="control-group">
              <div class="search-controls">
              		<label class="control-label2">姓名</label>
              		<input type="text" placeholder="Name" class="span2" id="usernm" >
              		<label class="control-label2">邮箱/手机号码</label>
              		<input type="text" placeholder="Phone or Email" class="span2" id="userPhoneEmail" >
              		<label class="control-label2">单位名称</label>
              		<input type="text" placeholder="Company Name" class="span3" id="companyName" >
              		<div class="button-search-right">
              			<input type="button" class="btn btn-success" value="检  索" id="searchButton" onclick="searchResult();">
              		</div>
              </div>
            </div>
        </div>
      </div>
    </div>
    
    <hr />
    <table id="tabGrid"></table>
    <div id="pager"></div>
  </body>
  <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery/jqGridUtil.js"></script>
    <script type="text/javascript">
	    jQuery(function(){
	    	var configAssessUser = {
	           	url:'<%=request.getContextPath() %>/xtgl/assessuser/assessUserList.html?doType=query',
	           	colModel:[
	           		{label:'user_id',name:"user_id",index:'user_id', key:true ,hidden:true},
	           		{label:'姓名',name:"user_nm",index:'user_nm'},
	           		{label:'邮箱',name:"user_email",index:'user_email'},
	           		{label:'手机号码',name:"user_phone",index:'user_phone'},
	           		{label:'单位名称',name:"company_name",index:'company_name'},
	           		{label:'是否被评估人',name:"isassess",index:'isassess'},
	           		{label:'上级(人)',name:"superiors",index:'superiors'},
	           		{label:'平级(人)',name:"equals",index:'equals'},
	           		{label:'下属(人)',name:"subordinates",index:'subordinates'},
	           		{label:'counts',name:"counts",index:'counts',hidden:true}
	           	],
	           	table:"#tabGrid",
	           	pager: "#pager",
	           	sortname: 'insert_dt',
	            sortorder: "desc",
	            caption:"用户信息列表"
	      };
	    	jQuery.loadGrid(configAssessUser);
	    	
	    	jQuery("#add").bind("click",function(){
	    			showDialog("增加用户",733,484,"<%=request.getContextPath() %>/xtgl/assessuser/assessUserAdd.html");
	    	});
	    	
	    	jQuery("#modify").bind("click",function(){
		    		//选中的行
	    			var ids = getChecked();
						if(ids.length!=1){
							alert("请先选定一条记录!");
							return false;
						}
						var url="<%=request.getContextPath() %>/xtgl/assessuser/assessUserMod.html"; 
						url+="?ids="+ids;
						showDialog('修改用户信息',733,484,url);
	    	});

	    	jQuery("#delete").bind("click",function(){

	    		//选中的行
	         var id = jQuery("#tabGrid").jqGrid('getGridParam', 'selarrrow');
	         for (var i = 0 ; i < id.length ; i++){
							var row = jQuery("#tabGrid").jqGrid('getRowData', id[i]);
							if(row.counts != "0"){
								alert("已有问卷发送给选择的用户，不能删除!");
								return false;
							}
	         }
	    		plcz("<%=request.getContextPath() %>/xtgl/assessuser/assessUserDel.html","删除");
	    	});

	    	jQuery("#import").bind("click",function(){
				  var url="<%=request.getContextPath() %>/xtgl/assessuser/assessUserImport.html";
	    		showDialog('导入用户信息',633,340,url);
	    	});
	    	
	    	jQuery("#setRelation").bind("click",function(){
	    		//选中的行
    			var ids = getChecked();
					if(ids.length!=1){
						alert("请先选定一条记录!");
						return false;
					}
					var url="<%=request.getContextPath() %>/xtgl/assessuser/assessUserSet.html"; 
					url+="?ids="+ids;
					showDialog('维护用户关系',728,547,url);
	    	});
	    });
	    
	    /**
		    * 检索
		    * @param tabId
		    * @param jsonMap
		    */
	    function searchResult() {
	    	var map = {};
	    	map["user_nm"] = jQuery('#usernm').val();
	    	map["user_phone"] = jQuery('#userPhoneEmail').val();
	    	map["company_name"] = jQuery('#companyName').val();
	    	search('tabGrid',map);
	    }

    </script>
</html>
